package com.hcw.bankdemob.mapper;

import com.hcw.bankdemob.model.TradeLog;
import org.apache.ibatis.annotations.*;

/**
 * @ClassName TradeLogMapper
 * @description:交易记录
 * @author: hcw
 * @time: 2020/9/1 17:24
 */
@Mapper
public interface TradeLogMapper {
    /**
     * @description: 根据id查询交易记录
     * @param
     * @return:
     * @author: hcw
     * @time: 2020/9/1 17:29
     */
    @Select("SELECT * FROM trade_log WHERE id=#{id}")
    TradeLog getTradeLogById(int id);

    /**
     * @description: 更新交易记录
     * @param
     * @return:
     * @author: hcw
     * @time: 2020/9/1 17:36
     */
    @Update("UPDATE trade_log SET status=#{status} ,failReason = #{failReason} where id=#{id}")
    Integer updateTradeLogById(int id, int status, String failReason);

    /**
     * @description: 插入交易记录
     * @param
     * @return:
     * @author: hcw
     * @time: 2020/9/1 17:44
     */
    @Insert("insert into trade_log(fromName,toName,money,dateTime,status,failReason,aId) values(#{fromName},#{toName},#{money},#{dateTime},#{status},#{failReason},#{aId})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    Integer insertTradeLog(TradeLog tradeLog);
}